<template>
  <div class="app-container">

    <el-table v-loading="loading" :data="userList" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center"/>
      <el-table-column label="${编号}" align="center" prop="id"/>
      <el-table-column label="司机注册地行政区划代码" align="center" prop="address"/>
      <el-table-column label="司机姓名" align="center" prop="driverName"/>
      <el-table-column label="${comment}" align="center" prop="driverPhone"/>
      <el-table-column label="1:男，2：女" align="center" prop="driverGender"/>
      <el-table-column label="${生日}" align="center" prop="driverBirthday" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.driverBirthday, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="驾驶员民族" align="center" prop="driverNation"/>
      <el-table-column label="${comment}" align="center" prop="driverContactAddress"/>
      <el-table-column label="机动车驾驶证号" align="center" prop="licenseId"/>
      <el-table-column label="初次领取驾驶证日期" align="center" prop="getDriverLicenseDate" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.getDriverLicenseDate, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="驾驶证有效期起" align="center" prop="driverLicenseOn" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.driverLicenseOn, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="驾驶证有效期止" align="center" prop="driverLicenseOff" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.driverLicenseOff, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="是否巡游出租汽车：1：是，0：否" align="center" prop="taxiDriver"/>
      <el-table-column label="网络预约出租汽车驾驶员资格证号" align="center" prop="certificateNo"/>
      <el-table-column label="网络预约出租汽车驾驶员发证机构" align="center" prop="networkCarIssueOrganization"/>
      <el-table-column label="资格证发证日期" align="center" prop="networkCarIssueDate" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.networkCarIssueDate, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="初次领取资格证日期" align="center" prop="getNetworkCarProofDate" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.getNetworkCarProofDate, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="资格证有效起始日期" align="center" prop="networkCarProofOn" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.networkCarProofOn, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="资格证有效截止日期" align="center" prop="networkCarProofOff" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.networkCarProofOff, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="报备日期" align="center" prop="registerDate" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.registerDate, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="服务类型：1：网络预约出租汽车，2：巡游出租汽车，3：私人小客车合乘" align="center"
                       prop="commercialType"/>
      <el-table-column label="驾驶员合同" align="center" prop="contractCompany"/>
      <el-table-column label="合同" align="center" prop="contractOn" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.contractOn, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="合同有效期止" align="center" prop="contractOff" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.contractOff, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="司机状态：0：有效，1：失效" align="center" prop="state"/>
      <el-table-column label="创建时间" align="center" prop="gmtCreate" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.gmtCreate, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="修改时间" align="center" prop="gmtModified" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.gmtModified, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['system:user:edit']"
          >查看
          </el-button>
        </template>
      </el-table-column>
    </el-table>


    <!-- 添加或修改【请填写功能名称】对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="1000px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="200px">
        <el-form-item label="司机注册地行政区划代码" prop="address">
          <el-input v-model="form.address" placeholder="请输入司机注册地行政区划代码"/>
        </el-form-item>
        <el-form-item label="司机姓名" prop="driverName">
          <el-input v-model="form.driverName" placeholder="请输入司机姓名"/>
        </el-form-item>
        <el-form-item label="${comment}" prop="driverPhone">
          <el-input v-model="form.driverPhone" placeholder="请输入${comment}"/>
        </el-form-item>
        <el-form-item label="1:男，2：女" prop="driverGender">
          <el-input v-model="form.driverGender" placeholder="请输入1:男，2：女"/>
        </el-form-item>
        <el-form-item label="${comment}" prop="driverBirthday">
          <el-date-picker clearable
                          v-model="form.driverBirthday"
                          type="date"
                          value-format="yyyy-MM-dd"
                          placeholder="请选择${comment}">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="驾驶员民族" prop="driverNation">
          <el-input v-model="form.driverNation" placeholder="请输入驾驶员民族"/>
        </el-form-item>
        <el-form-item label="${comment}" prop="driverContactAddress">
          <el-input v-model="form.driverContactAddress" placeholder="请输入${comment}"/>
        </el-form-item>
        <el-form-item label="机动车驾驶证号" prop="licenseId">
          <el-input v-model="form.licenseId" placeholder="请输入机动车驾驶证号"/>
        </el-form-item>
        <el-form-item label="初次领取驾驶证日期" prop="getDriverLicenseDate">
          <el-date-picker clearable
                          v-model="form.getDriverLicenseDate"
                          type="date"
                          value-format="yyyy-MM-dd"
                          placeholder="请选择初次领取驾驶证日期">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="驾驶证有效期起" prop="driverLicenseOn">
          <el-date-picker clearable
                          v-model="form.driverLicenseOn"
                          type="date"
                          value-format="yyyy-MM-dd"
                          placeholder="请选择驾驶证有效期起">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="驾驶证有效期止" prop="driverLicenseOff">
          <el-date-picker clearable
                          v-model="form.driverLicenseOff"
                          type="date"
                          value-format="yyyy-MM-dd"
                          placeholder="请选择驾驶证有效期止">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="是否巡游出租汽车：1：是，0：否" prop="taxiDriver">
          <el-input v-model="form.taxiDriver" placeholder="请输入是否巡游出租汽车：1：是，0：否"/>
        </el-form-item>
        <el-form-item label="网络预约出租汽车驾驶员资格证号" prop="certificateNo">
          <el-input v-model="form.certificateNo" placeholder="请输入网络预约出租汽车驾驶员资格证号"/>
        </el-form-item>
        <el-form-item label="网络预约出租汽车驾驶员发证机构" prop="networkCarIssueOrganization">
          <el-input v-model="form.networkCarIssueOrganization" placeholder="请输入网络预约出租汽车驾驶员发证机构"/>
        </el-form-item>
        <el-form-item label="资格证发证日期" prop="networkCarIssueDate">
          <el-date-picker clearable
                          v-model="form.networkCarIssueDate"
                          type="date"
                          value-format="yyyy-MM-dd"
                          placeholder="请选择资格证发证日期">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="初次领取资格证日期" prop="getNetworkCarProofDate">
          <el-date-picker clearable
                          v-model="form.getNetworkCarProofDate"
                          type="date"
                          value-format="yyyy-MM-dd"
                          placeholder="请选择初次领取资格证日期">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="资格证有效起始日期" prop="networkCarProofOn">
          <el-date-picker clearable
                          v-model="form.networkCarProofOn"
                          type="date"
                          value-format="yyyy-MM-dd"
                          placeholder="请选择资格证有效起始日期">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="资格证有效截止日期" prop="networkCarProofOff">
          <el-date-picker clearable
                          v-model="form.networkCarProofOff"
                          type="date"
                          value-format="yyyy-MM-dd"
                          placeholder="请选择资格证有效截止日期">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="报备日期" prop="registerDate">
          <el-date-picker clearable
                          v-model="form.registerDate"
                          type="date"
                          value-format="yyyy-MM-dd"
                          placeholder="请选择报备日期">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="驾驶员合同" prop="contractCompany">
          <el-input v-model="form.contractCompany" placeholder="请输入驾驶员合同"/>
        </el-form-item>
        <el-form-item label="合同" prop="contractOn">
          <el-date-picker clearable
                          v-model="form.contractOn"
                          type="date"
                          value-format="yyyy-MM-dd"
                          placeholder="请选择合同">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="合同有效期止" prop="contractOff">
          <el-date-picker clearable
                          v-model="form.contractOff"
                          type="date"
                          value-format="yyyy-MM-dd"
                          placeholder="请选择合同有效期止">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="司机状态：0：有效，1：失效" prop="state">
          <el-input v-model="form.state" placeholder="请输入司机状态：0：有效，1：失效"/>
        </el-form-item>
        <el-form-item label="创建时间" prop="gmtCreate">
          <el-date-picker clearable
                          v-model="form.gmtCreate"
                          type="date"
                          value-format="yyyy-MM-dd"
                          placeholder="请选择创建时间">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="修改时间" prop="gmtModified">
          <el-date-picker clearable
                          v-model="form.gmtModified"
                          type="date"
                          value-format="yyyy-MM-dd"
                          placeholder="请选择修改时间">
          </el-date-picker>
        </el-form-item>

        <el-form-item label="驳回原因" prop="causeOfRejection">
          <el-input v-model="form.causeOfRejection" placeholder="请输入驳回原因" />
        </el-form-item>

      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">通 过</el-button>
        <el-button @click="cancel">驳 回</el-button>
      </div>
    </el-dialog>


    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

  </div>
</template>

<script>
import {listUser, getUser, passTheExamination, reviewAndReject} from "@/api/platform/user";

export default {
  name: "User",
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 【请填写功能名称】表格数据
      userList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        address: null,
        driverName: null,
        driverPhone: null,
        driverGender: null,
        driverBirthday: null,
        driverNation: null,
        driverContactAddress: null,
        licenseId: null,
        getDriverLicenseDate: null,
        driverLicenseOn: null,
        driverLicenseOff: null,
        taxiDriver: null,
        certificateNo: null,
        networkCarIssueOrganization: null,
        networkCarIssueDate: null,
        getNetworkCarProofDate: null,
        networkCarProofOn: null,
        networkCarProofOff: null,
        registerDate: null,
        commercialType: null,
        contractCompany: null,
        contractOn: null,
        contractOff: null,
        state: null,
        gmtCreate: null,
        gmtModified: null,
        causeOfRejection: null
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {}
    };
  },
  created() {
    this.getList();
  },
  methods: {
    /** 查询【请填写功能名称】列表 */
    getList() {
      this.loading = true;
      listUser(this.queryParams).then(response => {
        this.userList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
      listUser().then(res => {
        this.userList = res;
      })
    },
    // 审核驳回按钮
    cancel() {
      reviewAndReject(this.form).then(res=> {
        console.log(res);
      })
      this.open = false;
      this.reset();

    },
    // 表单重置
    reset() {
      this.form = {
        id: null,
        address: null,
        driverName: null,
        driverPhone: null,
        driverGender: null,
        driverBirthday: null,
        driverNation: null,
        driverContactAddress: null,
        licenseId: null,
        getDriverLicenseDate: null,
        driverLicenseOn: null,
        driverLicenseOff: null,
        taxiDriver: null,
        certificateNo: null,
        networkCarIssueOrganization: null,
        networkCarIssueDate: null,
        getNetworkCarProofDate: null,
        networkCarProofOn: null,
        networkCarProofOff: null,
        registerDate: null,
        commercialType: null,
        contractCompany: null,
        contractOn: null,
        contractOff: null,
        state: null,
        gmtCreate: null,
        gmtModified: null
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    /** 根据id查看详细信息的按钮操作 */
    handleUpdate(row) {
      this.reset();
      const id = row.id
      getUser(id).then(response => {
        this.form = response.data;
        this.open = true;
        this.title = "查看详情【请填写功能名称】";
      });
      getUser(id).then(res => {
        this.open = true;
        this.form = res;
        console.log(this.form)
      })
    },
    /** 审核通过按钮 */
    submitForm() {
      // this.$refs["form"].validate(valid => {
      //   if (valid) {
      //     if (this.form.id != null) {
      //       updateUser(this.form).then(response => {
      //         this.$modal.msgSuccess("修改成功");
      //         this.open = false;
      //         this.getList();
      //       });
      //     } else {
      //       addUser(this.form).then(response => {
      //         this.$modal.msgSuccess("新增成功");
      //         this.open = false;
      //         this.getList();
      //       });
      //     }
      //   }
      // });

      console.log(this.form.id)
      let id = this.form.id;
      passTheExamination(id).then(res => {
        this.open = false;
        alert(res)
      })
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const ids = row.id || this.ids;
      this.$modal.confirm('是否确认删除【请填写功能名称】编号为"' + ids + '"的数据项？').then(function () {
        return delUser(ids);
      }).then(() => {
        this.getList();
        this.$modal.msgSuccess("删除成功");
      }).catch(() => {
      });
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download('system/user/export', {
        ...this.queryParams
      }, `user_${new Date().getTime()}.xlsx`)
    }
  }
};
</script>
